<?php

namespace Xrfg\Api\Trading\Home\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;
use Xrfg\Core\Trading\Account\Models\Coin;
use Xrfg\Api\Trading\Home\Resources\CoinToBtcResource;
use Xrfg\Api\Trading\Home\Resources\CoinToUsdtResource;

class TickerController extends Controller
{
    /**
     * USDT和BTC对人民币价格.
     */
    public function cny()
    {
        return $this->array([
            'usdt_to_cny' => Cache::get('ticker:okex.com:otc:usdt')['price_cny'] * 1,
            'btc_to_cny' => Cache::get('ticker:okex.com:otc:btc')['price_cny'] * 1,
        ]);
    }

    /**
     * 币种对USDT价格.
     */
    public function coinToUsdt()
    {
        $coins = Coin::all();

        return CoinToUsdtResource::collection($coins);
    }

    /**
     * 币种对BTC价格.
     */
    public function coinToBtc()
    {
        $coins = Coin::all();

        return CoinToBtcResource::collection($coins);
    }
}
